package com.itheima.wallet.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.wallet.api.TradeService;
import com.itheima.wallet.common.domain.Trade;
import com.itheima.wallet.common.mapper.TradeMapper;
import org.apache.dubbo.config.annotation.Service;

import java.util.List;


@Service
public class TradeServiceImpl extends ServiceImpl<TradeMapper, Trade> implements TradeService {

    /**
     * 插入账单记录
     *
     * @param trade
     * @return
     */
    @Override
    public Boolean insertTrade(Trade trade) {
        return super.save(trade);
    }

    /**
     * 分页查询用户的账单
     *
     * @param page
     * @param pageSize
     * @param account_id
     * @return
     */
    @Override
    public List<Trade> queryTradeList(Integer page, Integer pageSize, String account_id) {
        Page<Trade> tradePage = new Page<>(page, pageSize);
        QueryWrapper<Trade> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("account_id", account_id);
        return super.page(tradePage, queryWrapper).getRecords();
    }
}
